package Java_Lab.Multithreading.ThreadPool;

public class NotifyingThread extends Thread{
	
	private ThreadCompleteListener listener;
	
	public NotifyingThread(Runnable task, ThreadCompleteListener listener) {
		super(task);
		setListener(listener);
	}
	
	public void setListener(ThreadCompleteListener listener){
		this.listener = listener;
	}
	
	@Override
	public void run(){
		try{
			super.run();
		} finally {
			listener.notifyOfThreadComplete();
		}
	}
}
